//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Controls;

namespace OpenLS.Chart.UI
{
    partial class AxisPropertiesResources
    {
        public AxisPropertiesResources()
        {
            InitializeComponent();
        }

        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count != 1)
                return;
            var cb = (ComboBox)sender;
            var axis = (ValueAxis)cb.DataContext;
            if (e.AddedItems[0] is CustomUnit)
            {
                axis.DisplayUnits = null;
                return;
            }
            if (axis.DisplayUnits == null)
                axis.DisplayUnits = new DisplayUnits
                {
                    Label = new DisplayUnitsLabel()
                }
            ;
            axis.DisplayUnits.Unit = (Unit) e.AddedItems[0];
        }
    }
}
